const headerUrl = 'https://plomaster.cc/read/'
//登录
export const enroll = (phone, pwd) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/enroll`,
			method: 'POST',
			data: {
				phone,
				pwd
			},
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}
//注册
export const login = (name, phone, title, pwd) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/login`,
			method: 'POST',
			data: {
				name,
				phone,
				title,
				pwd
			},
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
		})
	})
}

//添加用户主题
export const addtheme = (id,size,textcolor,bgcolor) => {
	
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/addtheme`,
			method: 'POST',
			data:{
				id,
				size,
				textcolor,
				bgcolor
			},
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}
//查询用户主题
export const selecttheme = (id) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/selecttheme?id=${id}`,
			method: 'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}
//添加用户历史记录
export const addhistory = (id,ids,time) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/addhistory?uuid=${id}&userid=${ids}&time=${time}`,
			method: 'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}
//查询用户历史记录
export const selecthistory = (id) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/selecthistory?id=${id}`,
			method: 'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}
//添加用户书架
export const addshujia = (id,ids,time,zhangjie) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/addshujia?uuid=${id}&userid=${ids}&time=${time}&zhangjie=${zhangjie}`,
			method: 'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}
//查询用户书架
export const selectshujia = (id) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}/selectshujia?id=${id}`,
			method: 'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}
//删除用户书架
export const removeshujia = (id,uuid) => {
	console.log(`${headerUrl}removeshujia?id=${id}&uuid=${uuid}`,);
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}removeshujia?id=${id}&uuid=${uuid}`,
			method: 'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}

//删除用户历史记录
export const removehistory = (id,uuid) => {
	return new Promise((res, rej) => {
		uni.request({
			url: `${headerUrl}removehistory?id=${id}&uuid=${uuid}`,
			method: 'GET',
			success(conent) {
				res(conent)
			},
			fail(err) {
				rej(err)
			}
			
		})
	})
}

